package com.prd.controller;


import com.prd.dto.CustomerGuestDTO;
import com.prd.service.CustomerGuestService;
import com.prd.util.JsonData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 客户-客人总表 前端控制器
 * </p>
 *
 * @author o1
 * @since 2023-11-27
 */
@Api(tags={"客户管理-客人"})
@RestController
@RequestMapping("/api/customerGuest")
public class CustomerGuestController {

    private CustomerGuestService guestService;

    public CustomerGuestController(CustomerGuestService guestService) {
        this.guestService = guestService;
    }

    @ApiOperation("客户模块-UNI-客人-简易报备")
    @PostMapping(value = "uAddSimple", produces = "application/json;charset=UTF-8")
    public JsonData uAddSimple(
            @ApiParam(value = "uAddSimple") @RequestBody CustomerGuestDTO guestDTO) {
        return guestService.uAddSimple(guestDTO);
    }

    @ApiOperation("客户模块-UNI-客人-合并简易报备")
    @PostMapping(value = "uMerge", produces = "application/json;charset=UTF-8")
    public JsonData uMerge(
            @ApiParam(value = "uMerge") @RequestBody CustomerGuestDTO guestDTO) {
        return guestService.uMerge(guestDTO);
    }

    @ApiOperation("客户模块-UNI-客人-新增详细报备")
    @PostMapping(value = "uAddDetail", produces = "application/json;charset=UTF-8")
    public JsonData uAddDetail(
            @ApiParam(value = "uAddDetail") @RequestBody CustomerGuestDTO guestDTO) {
        return guestService.uAddDetail(guestDTO);
    }

    @ApiOperation("客户模块-客户-UNI-修改报备")
    @PostMapping(value = "uUpdateDetail", produces = "application/json;charset=UTF-8")
    public JsonData uUpdateDetail(
            @ApiParam(value = "uUpdateDetail") @RequestBody CustomerGuestDTO guestDTO) {
        return guestService.uUpdateAndAdd(guestDTO);
    }

    @ApiOperation("客户模块-客人-UNI-报备详情")
    @GetMapping("uInfo")
    public JsonData uInfo(
            @ApiParam(value = "客人编号") @RequestParam(value = "guestNo", defaultValue = "") String guestNo) {
        return guestService.uInfo(guestNo);
    }
    @ApiOperation("客户模块-客人-UNI-客人名录列表（条件+分页）")
    @GetMapping("uSearch")
    public JsonData uSearch(
            @ApiParam(value = "当前页数") @RequestParam(value = "page", defaultValue = "1") int page,
            @ApiParam(value = "当页数目") @RequestParam(value = "size", defaultValue = "10") int size,
            @ApiParam(value = "关键字") @RequestParam(value = "keyWord", defaultValue = "") String keyWord,
            @ApiParam(value = "客户类型") @RequestParam(value = "customerType", defaultValue = "-1") int customerType,
            @ApiParam(value = "客户状态") @RequestParam(value = "customerStatus", defaultValue = "-1") int customerStatus,
            @ApiParam(value = "排序: 效益金额1，创建时间2，同行类别3") @RequestParam(value = "softOf", defaultValue = "-1") int softOf,
            @ApiParam(value = "是否为倒序，倒序1，正序不填或者非1") @RequestParam(value = "orderBy", defaultValue = "-1") int orderBy,
            @ApiParam(value = "地区") @RequestParam(value = "address", defaultValue = "") String address,
            @ApiParam(value = "客人类别: A类1，B类2，C类3 ... ") @RequestParam(value = "guestLevel", defaultValue = "-1") int guestLevel,
            @ApiParam(value = "业务进度") @RequestParam(value = "businessStatus", defaultValue = "-1") int businessStatus,
            @ApiParam(value = "距离上次来往/联系：1周内是7，2周内是14，按天数以此类推") @RequestParam(value = "lastBusinessDay", defaultValue = "-1") int lastBusinessDay) {
        Map<String, Object> guestDTOList = guestService.uQueryGuest(page, size, keyWord, customerType, customerStatus, softOf, orderBy, address, guestLevel, businessStatus, lastBusinessDay);
        return JsonData.buildSuccess(guestDTOList);
    }

    @ApiOperation("客户模块-客人-UNI-客人名录列表（条件+不分页）")
    @GetMapping("uSearch2")
    public JsonData uSearch2(
            @ApiParam(value = "关键字") @RequestParam(value = "keyWord", defaultValue = "") String keyWord,
            @ApiParam(value = "客户类型") @RequestParam(value = "customerType", defaultValue = "-1") int customerType,
            @ApiParam(value = "客户状态") @RequestParam(value = "customerStatus", defaultValue = "-1") int customerStatus,
            @ApiParam(value = "排序: 效益金额1，创建时间2，同行类别3") @RequestParam(value = "softOf", defaultValue = "-1") int softOf,
            @ApiParam(value = "是否为倒序，倒序1，正序不填或者非1") @RequestParam(value = "orderBy", defaultValue = "-1") int orderBy,
            @ApiParam(value = "地区") @RequestParam(value = "address", defaultValue = "") String address,
            @ApiParam(value = "客人类别: A类1，B类2，C类3 ... ") @RequestParam(value = "guestLevel", defaultValue = "-1") int guestLevel,
            @ApiParam(value = "业务进度") @RequestParam(value = "businessStatus", defaultValue = "-1") int businessStatus,
            @ApiParam(value = "距离上次来往/联系：1周内是7，2周内是14，按天数以此类推") @RequestParam(value = "lastBusinessDay", defaultValue = "-1") int lastBusinessDay) {
        List<CustomerGuestDTO> guestDTOList = guestService.uQueryGuest2(keyWord, customerType, customerStatus, softOf, orderBy, address, guestLevel, businessStatus, lastBusinessDay);
        return JsonData.buildSuccess(guestDTOList);
    }

    @ApiOperation("客户模块-客人-UNI-客人名录列表-移除客户")
    @GetMapping("uRemoveCustomer")
    public JsonData uRemoveCustomer(@ApiParam(value = "客户编号") @RequestParam(value = "customerNo", defaultValue = "") String customerNo,
                                    @ApiParam(value = "客人编号") @RequestParam(value = "guestNo", defaultValue = "") String guestNo
                                    ) {
        return guestService.uRemoveCustomer(customerNo, guestNo);
    }

    @ApiOperation("客户模块-UNI-编辑详细信息")
    @PostMapping(value = "uAddAndUpdateDetail", produces = "application/json;charset=UTF-8")
    public JsonData uAddAndUpdateDetail(
            @ApiParam(value = "CustomerGuestDTO") @RequestBody CustomerGuestDTO guestDTO) {
        return guestService.uAddAndUpdateDetail(guestDTO);
    }

    @ApiOperation("客户模块-UNI-获得详细信息")
    @GetMapping(value = "uGetDetailInfo")
    public JsonData uGetDetailInfo(
            @ApiParam(value = "客人编号") @RequestParam(value = "guestNo", defaultValue = "") String guestNo) {
        return guestService.uGetDetailInfo(guestNo);
    }

    @ApiOperation("客户模块-客人-UNI-列表详情")
    @GetMapping("uInfo2")
    public JsonData uInfo2(
            @ApiParam(value = "客人编号") @RequestParam(value = "guestNo", defaultValue = "") String guestNo) {
        return guestService.uInfo2(guestNo);
    }
}

